from system.object import Object
from system.eventServer import eventServer

class Map(Object):
    def __init__(self, parent, type = None, name = None):
        Object.__init__(self, parent, type, name)
        
        for name, val in self.vars.iteritems():
            funcName = 'load_%s' % name
            if hasattr(self,funcName) and callable(getattr(self,funcName)):
                getattr(self,funcName)(val)
                
    def load_units(self, data):
        for name, unitData in data.iteritems():
            if not unitData.has_key('type'):
                unitData['type'] = name.split('_')[0]
            eventServer.pull('createUnit',unitData)
